﻿#ifndef SYSCFG_H
#define SYSCFG_H

#include <QString>
#include <QMutex>

class SysCfg
{
public:
    SysCfg();

    static int getIntValue(QString key, int defaultValue, int miniValue = 0);

    static QString getValue(QString key, QString defaultValue);

    static int saveIntValue(QString key, int value);

    static int saveValue(QString key, QString value);


};

#define DEFAILT_LISTEN_PORT 7500

#define  KEY_DEFAILT_LISTEN_PORT "KEY_DEFAILT_LISTEN_PORT"

#define LISTEN_PORT SysCfg::getIntValue(KEY_DEFAILT_LISTEN_PORT, DEFAILT_LISTEN_PORT)
#define SAVE_LISTEN_PORT(value) SysCfg::saveIntValue(KEY_DEFAILT_LISTEN_PORT, value)


#define  DEFAULT_CPU_ALARM_THRESHOLD 80
#define  DEFAULT_CPU_CHECK_INTERVAL_SECONDS 60

#define  KEY_CPU_ALARM_THRESHOLD "KEY_CPU_ALARM_THRESHOLD"
#define  KEY_CPU_CHECK_INTERVAL_SECONDS "KEY_CPU_CHECK_INTERVAL_SECONDS"


#define CPU_ALARM_THRESHOLD SysCfg::getIntValue(KEY_CPU_ALARM_THRESHOLD, DEFAULT_CPU_ALARM_THRESHOLD, 1)
#define SAVE_CPU_ALARM_THRESHOLD(value) SysCfg::saveIntValue(KEY_CPU_ALARM_THRESHOLD, value)

#define CPU_CHECK_INTERVAL_SECONDS SysCfg::getIntValue(KEY_CPU_CHECK_INTERVAL_SECONDS, DEFAULT_CPU_CHECK_INTERVAL_SECONDS, 2)
#define SAVE_CPU_CHECK_INTERVAL_SECONDS(value) SysCfg::saveIntValue(KEY_CPU_CHECK_INTERVAL_SECONDS, value)


#define  DEFAULT_MEM_ALARM_THRESHOLD 80
#define  DEFAULT_MEM_CHECK_INTERVAL_SECONDS 30

#define  KEY_MEM_ALARM_THRESHOLD "KEY_MEM_ALARM_THRESHOLD"
#define  KEY_MEM_CHECK_INTERVAL_SECONDS "KEY_MEM_CHECK_INTERVAL_SECONDS"

#define MEM_ALARM_THRESHOLD SysCfg::getIntValue(KEY_MEM_ALARM_THRESHOLD, DEFAULT_MEM_ALARM_THRESHOLD, 1)
#define SAVE_MEM_ALARM_THRESHOLD(value) SysCfg::saveIntValue(KEY_MEM_ALARM_THRESHOLD, value)

#define MEM_CHECK_INTERVAL_SECONDS SysCfg::getIntValue(KEY_MEM_CHECK_INTERVAL_SECONDS, DEFAULT_MEM_CHECK_INTERVAL_SECONDS,2)
#define SAVE_MEM_CHECK_INTERVAL_SECONDS(value) SysCfg::saveIntValue(KEY_MEM_CHECK_INTERVAL_SECONDS, value)


#define  DEFAULT_DISK_ALARM_THRESHOLD 90
#define  DEFAULT_DISK_CHECK_INTERVAL_SECONDS 60

#define  KEY_DISK_ALARM_THRESHOLD "KEY_DISK_ALARM_THRESHOLD"
#define  KEY_DISK_CHECK_INTERVAL_SECONDS "KEY_DISK_CHECK_INTERVAL_SECONDS"

#define DISK_ALARM_THRESHOLD SysCfg::getIntValue(KEY_DISK_ALARM_THRESHOLD, DEFAULT_DISK_ALARM_THRESHOLD,1)
#define SAVE_DISK_ALARM_THRESHOLD(value) SysCfg::saveIntValue(KEY_DISK_ALARM_THRESHOLD, value)

#define DISK_CHECK_INTERVAL_SECONDS SysCfg::getIntValue(KEY_DISK_CHECK_INTERVAL_SECONDS, DEFAULT_DISK_CHECK_INTERVAL_SECONDS,2)
#define SAVE_DISK_CHECK_INTERVAL_SECONDS(value) SysCfg::saveIntValue(KEY_DISK_CHECK_INTERVAL_SECONDS, value)


#define DEFAULT_WATCHDOG_SERVER_PORT 7000

#define KEY_WATCHDOG_SERVER_IP "KEY_WATCHDOG_SERVER_IP"
#define KEY_WATCHDOG_SERVER_PORT "KEY_WATCHDOG_SERVER_PORT"

#define WATCHDOG_SERVER_IP SysCfg::getValue(KEY_WATCHDOG_SERVER_IP, "")
#define SAVE_WATCHDOG_SERVER_IP(value) SysCfg::saveValue(KEY_WATCHDOG_SERVER_IP, value)

#define WATCHDOG_SERVER_PORT SysCfg::getIntValue(KEY_WATCHDOG_SERVER_PORT, DEFAULT_WATCHDOG_SERVER_PORT)
#define SAVE_WATCHDOG_SERVER_PORT(value) SysCfg::saveIntValue(KEY_WATCHDOG_SERVER_PORT, value)


#define IMPORTANT_APPS "VIFaceFront,VIFaceCompare,VIFaceStore"


#define HEART_BEAT_INTERVAL_SECONDS 5

#define UPDATE_FILES_STORE_PATH "app_update"


#endif // SYSCFG_H
